def func():
    a = input()
    a = a.split(" ")
    # print(a)
    b = dict()
    # print(b)
    flag = 0
    k = 1
    try:
        for i in range(len(a)):
            if a[i][-2:-1] != "/":
                flag = 1
            c = a[i].split("/")
            # print(i)
            if 999 < int(c[0]) or int(c[0]) < 0:
                flag = 1
            if c[1] == "Y":
                b.get(k).add(int(c[0]))
            elif c[1] == "N":
                if k == 1:
                    k = 0
                elif k == 0:
                    k = 1
                if b.get(k):
                    b.get(k).add(int(c[0]))
                else:
                    b[k] = {int(c[0])}
            else:
                flag = 1

    except [IndexError, ValueError]:
        flag = 1
    ee = []
    if flag == 0:
        for i in sorted(b.items()):
            # print(list((i[1])))
            list3 = sorted(list((i[1])))
            # print(list3)
            ee.append(list3)

        for i in sorted(ee):
            list4 = list(map(str, i))
            list2 = ' '.join(list4)
            print(list2)
    else:
        print("ERROR")


if __name__ == '__main__':
    """
   3/N 4/Y 998/N 2/Y
    """
    func()
